#pragma once

#include <QObject>
#include <QtSerialPort/QtSerialPort> 

class SerialPortObject : public QObject
{
	Q_OBJECT

public:
	SerialPortObject(int type, QObject *parent = Q_NULLPTR);
	~SerialPortObject();
	void initData();

	bool openSerialPort(QString strPortName,int bitrate);
	void closeSerialPort();
	bool writeDataToSerialPort(QByteArray para);
	QList <QSerialPortInfo> getSerialPortList();

signals:
	void signalSendDataToMain(int type, QByteArray dataReceived);

	public slots:
	void SlotRefreshSerialPort();
	void SlotOpenSerialPort();
	void slotReadSerialPort();
	void SlotReceiveOrderFromMain(int deviceType,QByteArray dataForSend);

private:
	QList <QSerialPortInfo> m_infoList;
	QSerialPort* m_currentSerialPort;

	QString m_portName;
	int m_bitrate;
	int m_deviceType;
};
